/*
 * @Author: lg
 * @Date: 2023-08-31 17:10:02
 * @LastEditors: lg
 * @LastEditTime: 2024-06-12 10:45:42
 * @Description:
 * @FilePath: \ssii-user-bk\src\directives\btn-permission\index.ts
 */

import router from '@/router/index';
const { MODE } = import.meta.env;
export const btnPermission = {
  name: 'btnPermission',
  mounted(el: any, binding: any, vnode: any) {
    const btnPermissions: any =
      router.currentRoute?.value?.meta?.btnPermissions || [];
    // console.log(
    //   binding.value,
    //   '按钮权限-----binding-----------',
    //   btnPermissions,
    //   MODE
    // );
    if (!btnPermissions?.includes(binding.value[1]) && MODE !== 'dev') {
      el.parentNode && el.parentNode.removeChild(el); //移除元素
    }
  }
};
